referencing includes from the subfunction

sorry if was too bad with the search and reposted some thread, but..

DOORS 9.3, run dxl script with some includes:


#include <w:\Projects\Shared\Architecture\Tools\DOORS\CalprmExtractor\createArxml.inc> ... #include <w:\Projects\Shared\Architecture\Tools\DOORS\CalprmExtractor\filterOverLink.dxl>


main part:

CallSomeRoutineFromFirstInclude <- works just fine   CallSomeRoutineFromSecondInclude <-works just fine


and finally a chunk from "filterOverLink.dxl"


CallSomeRoutineFromFirstInclude
<-doesn't work, can't find the routine

Somebody knows the issue?
reincluding in the subroutine of course gives double declaration errors.
SystemAdmin - Wed Feb 08 10:05:58 EST 2012

Re: referencing includes from the subfunction
llandale - Wed Feb 08 16:49:57 EST 2012

  • If the first include is in some braced section then it will be invisible outside:
    • { #include..
    • }
    • code here cannot see it.
  • if function CallSomeRoutineFromFirstInclude has no parameters and you also have some variable with that exact name; not sure what will happen.
  • if you are using forward declarations after the function then I don't know also.
  • If you use nested functions, then again I'm not sure what will happen.

Look for all references to "CallSomeRoutineFromFirstInclude" in the 2nd include.

-Louie

Re: referencing includes from the subfunction
SystemAdmin - Fri Feb 10 07:40:31 EST 2012

llandale - Wed Feb 08 16:49:57 EST 2012

  • If the first include is in some braced section then it will be invisible outside:
    • { #include..
    • }
    • code here cannot see it.
  • if function CallSomeRoutineFromFirstInclude has no parameters and you also have some variable with that exact name; not sure what will happen.
  • if you are using forward declarations after the function then I don't know also.
  • If you use nested functions, then again I'm not sure what will happen.

Look for all references to "CallSomeRoutineFromFirstInclude" in the 2nd include.

-Louie

No brackets, no similar named variables no forward declaration.. In fact even the include order doesn'n make any difference.. If I call the function not from the subroutine but from the "main" module, where the includes are defined, then it works just fine!
So, as Louie just mentioned this could be an issue with nested functions..
Will look how it works with the forward declarations..

Re: referencing includes from the subfunction
llandale - Fri Feb 10 20:20:49 EST 2012

SystemAdmin - Fri Feb 10 07:40:31 EST 2012
No brackets, no similar named variables no forward declaration.. In fact even the include order doesn'n make any difference.. If I call the function not from the subroutine but from the "main" module, where the includes are defined, then it works just fine!
So, as Louie just mentioned this could be an issue with nested functions..
Will look how it works with the forward declarations..

If Include-1 defines function A and Include-2 calls A, AND you don't get an intepret error when Include-2 comes first, then I'm pretty sure that either
  • [1] Include-2 also defines function A, or
  • [2] A is a native perm or defined in the global context (in some DOORS supplied include file).
Try these
  • Comment out both includes and see if your "main" call to A still at least interprets. If so, then A is also in the global context.
  • In Include-1, Rename function A to A1 and see what happens; then nn Include-2, Rename the call to A to A1 and see what happens
  • I wonder if Include-B has some form of nested #Include-1; or visa-versa.
  • Perhaps Include-2 defines A at the bottom, but calls A near the top. If so, your main program would see A in Include-2 and work, but the call to A that is between the two functions gets confused. Try this; then un-comment out line 7 and try again:


// Include-1 

void A(string s) 
{   print 
"1st A: " s 
"\n" 
}   
// Include-2 
//A("Hello") 

void A(string s) 
{  print 
"2nd A: " s 
"\n" 
} A(
"Goodbye")


When the smoke clears and you realize you could have had some V-8, please let us know so the rest of us can avoid the same mistake.

-Louie

For whatever its worth, I have noticed the following "unique features" that do not give me reassurance about "context" stability:
  • A nested function cannot use variables defined in the Main function; making them practically worthless.
  • There has been intermittent issues with forward-declares.
  • There has been intermittent issues with counter-intuitive bracket "{" "}" contexts in rare situations.
  • Some Layout or displayed Attr-DXL jumps context into the next one.

Re: referencing includes from the subfunction
SystemAdmin - Mon Jul 16 06:25:14 EDT 2012

llandale - Fri Feb 10 20:20:49 EST 2012
If Include-1 defines function A and Include-2 calls A, AND you don't get an intepret error when Include-2 comes first, then I'm pretty sure that either

  • [1] Include-2 also defines function A, or
  • [2] A is a native perm or defined in the global context (in some DOORS supplied include file).
Try these
  • Comment out both includes and see if your "main" call to A still at least interprets. If so, then A is also in the global context.
  • In Include-1, Rename function A to A1 and see what happens; then nn Include-2, Rename the call to A to A1 and see what happens
  • I wonder if Include-B has some form of nested #Include-1; or visa-versa.
  • Perhaps Include-2 defines A at the bottom, but calls A near the top. If so, your main program would see A in Include-2 and work, but the call to A that is between the two functions gets confused. Try this; then un-comment out line 7 and try again:


// Include-1 

void A(string s) 
{   print 
"1st A: " s 
"\n" 
}   
// Include-2 
//A("Hello") 

void A(string s) 
{  print 
"2nd A: " s 
"\n" 
} A(
"Goodbye")


When the smoke clears and you realize you could have had some V-8, please let us know so the rest of us can avoid the same mistake.

-Louie

For whatever its worth, I have noticed the following "unique features" that do not give me reassurance about "context" stability:
  • A nested function cannot use variables defined in the Main function; making them practically worthless.
  • There has been intermittent issues with forward-declares.
  • There has been intermittent issues with counter-intuitive bracket "{" "}" contexts in rare situations.
  • Some Layout or displayed Attr-DXL jumps context into the next one.

sorry for the long pause - troubles by accessing the account..

well, after trying this and that I came to the for me suitable solution of avoid any nested function calls: I just put the code where I needed it. Of course this is not the answer of the question but I have limited time in the project, so even non-intelligent solutions could be accepted. :)

Re: referencing includes from the subfunction
SystemAdmin - Mon Jul 16 06:30:19 EDT 2012

llandale - Fri Feb 10 20:20:49 EST 2012
If Include-1 defines function A and Include-2 calls A, AND you don't get an intepret error when Include-2 comes first, then I'm pretty sure that either

  • [1] Include-2 also defines function A, or
  • [2] A is a native perm or defined in the global context (in some DOORS supplied include file).
Try these
  • Comment out both includes and see if your "main" call to A still at least interprets. If so, then A is also in the global context.
  • In Include-1, Rename function A to A1 and see what happens; then nn Include-2, Rename the call to A to A1 and see what happens
  • I wonder if Include-B has some form of nested #Include-1; or visa-versa.
  • Perhaps Include-2 defines A at the bottom, but calls A near the top. If so, your main program would see A in Include-2 and work, but the call to A that is between the two functions gets confused. Try this; then un-comment out line 7 and try again:


// Include-1 

void A(string s) 
{   print 
"1st A: " s 
"\n" 
}   
// Include-2 
//A("Hello") 

void A(string s) 
{  print 
"2nd A: " s 
"\n" 
} A(
"Goodbye")


When the smoke clears and you realize you could have had some V-8, please let us know so the rest of us can avoid the same mistake.

-Louie

For whatever its worth, I have noticed the following "unique features" that do not give me reassurance about "context" stability:
  • A nested function cannot use variables defined in the Main function; making them practically worthless.
  • There has been intermittent issues with forward-declares.
  • There has been intermittent issues with counter-intuitive bracket "{" "}" contexts in rare situations.
  • Some Layout or displayed Attr-DXL jumps context into the next one.

in aswer to llandale:
I do become error when Include-2 comes first (and when it comes second).

Basically I always try to include all subroutines in the main dxl to avoid any circular declarations..

Re: referencing includes from the subfunction
llandale - Mon Jul 16 15:02:50 EDT 2012

SystemAdmin - Mon Jul 16 06:25:14 EDT 2012
sorry for the long pause - troubles by accessing the account..

well, after trying this and that I came to the for me suitable solution of avoid any nested function calls: I just put the code where I needed it. Of course this is not the answer of the question but I have limited time in the project, so even non-intelligent solutions could be accepted. :)

My include files are in a fixed order, each Include adds a comment as to which other includes must be included first. Each is intended to be included in the Main context of a script. I do have some meta-includes that issues the basic includes in the correct order:

#include <Includes\Lib-LibBasic.inc> \\ Includes the bottom-most 9 includes
#include <Includes\Lib-Objects.inc> \\ This program needs these functions

If there is another scheme that works I'd like to hear it.

-Louie